package dao;

import dao.Entity.Place;
import dao.Entity.Places;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class QueryPlaces {

    public static Places getResult() {
        MyConnection myCon = new MyConnection();
        myCon.getConnection();
        Places places = null;
        try {
            PreparedStatement ps;

            ps = myCon.connection.prepareStatement(
                    "SELECT * FROM place where PlaceStatus!=2;");

            ResultSet rs = ps.executeQuery();
            places = new Places();
            while (rs.next()) {
                places.appendPlace(new Place(rs.getString(1), rs.getString(2), rs.getString(3), rs.getInt(4)));
            }
            ps.close();

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            myCon.closeConnection();
        }
        return places;
    }
}
